<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>文章列表</title>
    <style>
        form {
            width: 500px;
            text-align: center;
            margin-bottom: 20px;
        }
        .page {
            width: 500px;
            text-align: center;
            margin-top: 20px;
        }
    </style>
</head>
<body>
    <h1>文章列表</h1>
    <form method="get">
        <input type="search" name="keyword" value="{{ keyword }}">
        <button type="submit">搜索</button>
        <a href="/blog/add/">添加+</a>
    </form>
    <table border="1" cellspacing="0" width="500">
        <tr>
            <th>标题</th>
            <th>作者</th>
            <th>操作</th>
        </tr>
        {% for article in page_list %}
        <tr>
            <td>{{ article.title }}</td>
            <td align="center">{{ article.author }}</td>
            <td align="center">
                <a href="{% url 'page_edit' article.id %}">编辑</a>
                <a href="{% url 'page_delete' article.id %}" onclick="return confirm('确定要删除这篇文章吗？')">删除</a>
            </td>
        </tr>
        {% endfor %}
    </table>
    <div class="page">
        {% if page_list.has_previous %}
        <a href="?page_num={{ page_list.previous_page_number }}&page_size={{ page_size }}&keyword={{ keyword }}">上一页</a>
        {% endif %}
        <span>{{ page_list.number }}/{{ page_list.paginator.num_pages }}</span>
        {% if page_list.has_next %}
        <a href="?page_num={{ page_list.next_page_number }}&page_size={{ page_size }}&keyword={{ keyword }}">下一页</a>
        {% endif %}
    </div>
</body>
</html>
